package bank;

/**
 * 写一个名为 bank.Account 的类模拟账户。该类的属性和方法如下图所示。该类包括的属性：
 * 账号 id，余额 balance，年利率 annualInterestRate；包含的方法：访问器方法（getter 和 setter
 * 方法），取款方法 withdraw()，存款方法 deposit()
 */
public class Account {
    private int id;
    private double balance;
    private double annualInterestRate;

    public Account(int id, double balance, double annualInterestRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterestRate = annualInterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterestRate() {
        return annualInterestRate;
    }

    public void setAnnualInterestRate(double annualInterestRate) {
        this.annualInterestRate = annualInterestRate;
    }

    /**
     * 取款功能
     * @param amount 取款额
     */
    public void withdraw(double amount) {
        if (amount <= balance) {
            balance -= amount;
            System.out.println("成功取款：" + amount);
            System.out.println("现余额：" + balance);
        } else {
            System.out.println("余额不足！无法取款！");
        }
    }

    /**
     * 存款功能
     * @param amount 存款额
     */
    public void deposit(double amount) {
        balance += amount;
        System.out.println("成功存款：" + amount);
        System.out.println("现余额：" + balance);
    }

}
